package ClassCharacteristics;

/**
 * Created by XQ on 2017/5/24.
 */
public class OuterClass {
    class InnerClass{
        int innerParam = 0;
        public void innerFun(){
            System.out.println("This is innerFun");
        }
    }

//    在外部类方法，返回值为内部类引用
    public InnerClass doit(){
        return new InnerClass();
    }

//    在外部内实例化内部内对象引用
    InnerClass innerClass = new InnerClass();
    public void outFun(){
        innerClass.innerFun();
    }

//    在主方法中实例化内部类对象
    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        outerClass.outFun();

        OuterClass.InnerClass innerClass = outerClass.doit();
        innerClass.innerFun();

        OuterClass.InnerClass innerClass1 = outerClass.new InnerClass();//实例化内部类对象
        innerClass1.innerFun();


    }
}
